package com.example.sxproject.service.impl;

import com.example.sxproject.mapper.LoanMapper;
import com.example.sxproject.pojo.LoanProduct;
import com.example.sxproject.pojo.LoanUser;
import com.example.sxproject.service.LoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoanServiceImpl implements LoanService {

    @Autowired
    private LoanMapper loanMapper;

    //查询select：全部
    @Override
    public List<LoanProduct> SelectAll() {
        List<LoanProduct> products = loanMapper.SelectAll();
        return products;
    }

    //查询select：根据产品id查找
    @Override
    public LoanProduct SelectByProductId(Integer productId) {
        LoanProduct product = loanMapper.SelectByProductId(productId);
        return product;
    }

    //查询select：根据用户名查找
    @Override
    public List<LoanProduct> SelectByUserId(Integer userId) {
        List<LoanProduct> products = loanMapper.SelectByUserId(userId);
        return products;
    }

    //查询select：根据用户id查找
    @Override
    public List<LoanUser> findByUserId(Integer userId) {
        List<LoanUser> products = loanMapper.findByUserId(userId);
        return products;
    }

    //添加insert：添加一个产品
    @Override
    public void addLoanProduct(LoanProduct loanProduct) {
        loanMapper.addLoanProduct(loanProduct);
    }

    //添加insert：添加一个用户-贷款
    @Override
    public void addUserAndLoan(LoanUser loanUser) {
        loanMapper.addUserAndLoan(loanUser);
    }

    //更新update：更新记录
    @Override
    public void update(LoanProduct loanProduct) {
        loanMapper.update(loanProduct);
    }

    //更新update：更新用户-贷款
    @Override
    public void updateUP(LoanUser loanUser) {
        loanMapper.updateUP(loanUser);
    }

    //更新update：根据id进行假删除
    @Override
    public void delete(LoanProduct loanProduct) {
        loanMapper.delete(loanProduct);
    }

    //管理员贷款产品查询
    @Override
    public List<LoanProduct> selectNT(LoanProduct loanProduct) {
        return loanMapper.selectNT(loanProduct);
    }

    //查询用户申请
    @Override
    public List<LoanUser> selectApply() {
        return loanMapper.selectApply();
    }

    //查询用户贷款
    @Override
    public List<LoanUser> selectAllUser() {
        return loanMapper.selectAllUser();
    }

    //通过贷款申请
    @Override
    public void tongguo(Integer id){loanMapper.tongguo(id);}

    @Override
    public void jujue(Integer id){loanMapper.jujue(id);}
}
